let https = require('https');
let config = require('../config/config');
module.exports = {
    getOpenId(req, res, next){
        let jsCode = req.body.js_code;
        https.get("https://api.weixin.qq.com/sns/jscode2session?"+"appid="+config.appid+"&secret="+config.secret+"&js_code="+jsCode+"&grant_type=authorization_code", (result)=>{
            let data = '';

            result.on('data', function (chunk) {
                data += chunk;
                console.log(data)
            });

            result.on('end', function () {
                let result = JSON.parse(data);
                res.json({
                    "code": "0",
                    data: result,
                });

            })
        });
    },
};